import { FormItemProps } from 'antd/lib/form';
import { FormProps } from 'antd/lib/form/Form';
import { FunctionComponent } from 'react';

export interface NbFormScheme extends FormProps {
  name: string;
  properties: { [key: string]: NbFormItemScheme };
}

export interface NbFormItemScheme extends Omit<FormItemProps, 'name'> {
  properties?: { [key: string]: NbFormItemScheme };
  widget?: WidgetType;
  order?: number;
  props?: NbSchemeItem;
  render?: FunctionComponent<NbSchemeItem>;
  watch?: {};
  watchComProps?: {
    [key: string]: (value: any, values: any) => {};
  };
  watchItemProps?: {
    [key: string]: (value: any, values: any) => NbSchemeItem;
  };
}

export type WidgetType =
  | 'object'
  | 'input'
  | 'inputNumber'
  | 'radioGroup'
  | 'select'
  | 'switch';

export interface NbSchemeItem {
  value?: any;
  onChange?: (value?: any, args?: any) => void;
}
